package ru.home.shoppinglist;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DBHelper extends SQLiteOpenHelper {

	private static final String LOG_TAG = "DBHelper";

	public DBHelper(Context context) {
		// конструктор суперкласса
		super(context, "ShoppingList", null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		Log.d(LOG_TAG, "--- onCreate database ---");
		// создаем таблицу с полями
		Log.d(LOG_TAG, "--- Classification ---");
		db.execSQL("create table Classification ("
				+ "id integer primary key autoincrement," + "name text,"
				+ "parentid integer" + ");");
		Log.d(LOG_TAG, "--- Goods ---");
		db.execSQL("create table Goods ("
				+ "id integer primary key autoincrement,"
				+ "creation_date text," + "name text," + "priority integer,"
				+ "to_date text" + ");");
		Log.d(LOG_TAG, "--- GoodsClassification ---");
		db.execSQL("create table GoodsClassification ("
				+ "classification_id integer," + "goods_id integer" + ");");
		Log.d(LOG_TAG, "--- DB creation finished successfully ---");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

}
